<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>寻找比目标字母大的最小字母</title>
</head>
<body>
  <script>
    function fn(letters, target) {
      const length = letters.length;
      let nextGreater = letters[0];
      for (let i = 0; i < length; i++) {
          if (letters[i] > target) {
              nextGreater = letters[i];
              break;
          }
      }
      return nextGreater;
    }
    console.log(fn(['c', 'f', 'j'], 'a'))
  </script>
</body>
</html>